<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
import="java.util.*,com.admin.User,com.admin.Role"

%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
	String path = request.getContextPath();
%>
<%  Role role=(Role)request.getSession().getAttribute("user_roles");
 %>
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
  <link href="<%=path%>/css/bootstrap.min.css" rel="stylesheet">
<link href="<%=path%>/css/materialdesignicons.min.css" rel="stylesheet">
<link href="<%=path%>/css/style.min.css" rel="stylesheet">
<link href="<%=path%>/css/animate.css" rel="stylesheet">
 
</head>
  <div class="container-fluid p-t-15">
             <div class="row">
                 <div class="col-md-12">
                     <div class="card">
                         <div class="card-header"> <h4>修改密码</h4></div>
                         <div class="card">
                             <div class="card-body">
                                 <form class="form-horizontal" action="lyear_forms_elements.html" method="post" onsubmit="return false;">
                                     <div class="form-group">
                                         <label class="col-md-2 control-label">用户账号</label>
                                         <div class="col-md-4">
                                             <input class="form-control" id="yhzh" value="${session.login_user.usercode}" disabled>
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-md-2 control-label">用户姓名</label>
                                         <div class="col-md-4">
                                             <input class="form-control" value="${session.login_user.username}" disabled>
                                         </div>
                                     </div>
                                     
                                     <div class="form-group">
                                         <label class="col-md-2 control-label" ><span style="color:red">* </span>当前密码</label>
                                         <div class="col-md-4">
                                             <input class="form-control" type="password" id="pwd">
                                         </div>
                                         	
                                     </div>
                                     
                                     <div class="form-group">
                                         <label class="col-md-2 control-label"><span style="color:red">* </span>新密码</label>
                                         <div class="col-md-4">
                                             <input class="form-control" type="password" id="pwdnew">
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <label class="col-md-2 control-label"><span style="color:red">* </span>确认新密码</label>
                                         <div class="col-md-4">
                                             <input class="form-control" type="password" id="twopwd" >
                                         </div>
                                     </div>
                                     <div class="form-group">
                                         <div class="col-md-3 col-md-offset-2">
                                             <button class="btn btn-primary" id="tj" type="submit">&nbsp;提&nbsp;交&nbsp; </button>
                                         </div>
                                     </div>
                                 </form>
                             </div>
                         </div>
                     </div>
                 </div>
             </div>
         </div>
       
       
 <script type="text/javascript" src="<%=path%>/js/jquery.min.js"></script>
 <script type="text/javascript" src="<%=path%>/js/bootstrap-notify.min.js"></script>
 <script type="text/javascript" src="<%=path%>/js/lightyear.js"></script>      
 <script type="text/javascript">
 var pwd 	= document.getElementById("pwd");
 var newpwd 	= document.getElementById("pwdnew");
 var twopwd	= document.getElementById("twopwd");
 var code 	= document.getElementById("yhzh");
 $("#tj").click(function(){
	 
 	if(pwd.value == null || pwd.value ==""){
 	
    
    lightyear.notify('请填写你要修改的新密码!', 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
	  
 	}else if(newpwd.value == null || newpwd.value ==""){
 		lightyear.notify('请填写你要修改的新密码!', 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
 	  
 	}else if(newpwd.value == pwd.value){
 		
 		lightyear.notify('新密码不能与旧密码相同!', 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
    	   
 	 	}else if(twopwd.value == null || twopwd.value ==""){
 		lightyear.notify('请再次确认你要修改的新密码!', 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
   	   
 	 	}else if(twopwd.value!=newpwd.value){
 		lightyear.notify('你两次输入的新密码不一致!', 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
  	     
 	}else{
 		//填写完毕
 		lightyear.loading('show')
 		 $.ajax({
 	  			
 				dataType: "json",
 				type: "POST",
 				url: "<%=path%>/admin/passwordmod",
 				data: {
 					"newpassword":newpwd.value,
 					"password":pwd.value,
 					"usercode":code.value
 				},success: function(req) {	
 					lightyear.loading('hide');
 					
 					
 					if(req.msg=="修改成功!"){
 						lightyear.notify('修改成功，请重新登录~', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center')
 	 				    
 		 				
 	 					 setTimeout(function(){
 	 						window.parent.tuichu();
 	 						
 	            		 },1000);
 					}else{
 						lightyear.notify(req.msg, 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
 		 			   	  
 					}
					
 				},error: function(){ 
 					lightyear.notify('服务器错误，请稍后再试~', 'danger', 100, 'mdi mdi-emoticon-sad', 'top', 'center');
 			   	     

 	 				}
 			});		
 	}
 })
 </script>    
 
        
    </body>

</html>   
    
<!-- 创建账号按钮  -->			
